package umage.core;

import java.net.URL;
import java.util.MissingResourceException;

import javax.swing.ImageIcon;

public class ImageUtil {
	
	public static ImageIcon getImageIcon(String imageName, String imageDir) {
        try {
            if (imageName.equals("")) {
                return null;
            }
            if (!imageName.startsWith("/")) {
                imageName = imageDir + imageName;
            }

            URL url = ImageUtil.class.getResource(imageName);
            
            return (url == null) ? null : new ImageIcon(url);
        } catch (MissingResourceException e) {
            return null;
        }
	}
	
}
